// 玩家
cc.Class({
    extends: cc.Component,

    properties: {
        // 玩家信息
        playerInfo: {
            type: cc.Node,
            default: null,
        },
        namePlate: {
            type: cc.Node,
            default: null,
        },
        playerPhoto: {
            type: cc.Sprite,
            default: null,
        },
        countDown: {
            type: cc.ProgressBar,
            default: null,
        },
        // 筹码节点
        stakeOnTable: {
            type: cc.Node,
            default: null,
        },
        // 筹码
        stakeNumOnTable: {
            type: cc.Label,
            default: null,
        },
        // 动效
        fxPlayer: {
            type: cc.Node,
            default: null,
        },
        cardInfo: {
            type: cc.Node,
            default: null,
        }

    },

    initWithModel(model, playerInfoPos, stakeTablePos, photo) {
        this.model = model;
        // 玩家名字
        this.playerName = this.namePlate.getChildByName("playerName");
        // 玩家筹码
        this.playerStake = this.namePlate.getChildByName("stakeNum");
        // 爆牌、停牌等
        this.cardText = this.cardInfo.getChildByName("text");
        // 卡片背景
        this.cardBackground = this.cardInfo.getChildByName("bg");
        // index >= 3，将 playerStake，playerName，namePlate, cardInfo 沿x轴放大-1倍
        if(this.model.index >= 3) {
            this.namePlate.scaleX = -this.namePlate.scaleX;
            this.playerStake.scaleX = -this.playerStake.scaleX;
            this.playerName.scaleX = -this.playerName.scaleX;
        }
        this.stakeOnTable.position = stakeTablePos;
        this.playerInfo.position = playerInfoPos;
        // 设置头像
        this.playerPhoto.spriteFrame = photo;
        this.fxPlayer.active = false;
        this.cardInfo.active = false;
    },

    // 更新筹码
    updateStake() {
        this.stakeNumOnTable.string = this.model.currentStake;
        this.playerStake.getComponent(cc.Label).string = "$"+this.model.gold;
    },

    reset: function() {

    },

});
